package org.javaboy.demo;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.Date;

/**
 * @author Lyh
 * @date 2024/2/20 1:34
 * @desciption:
 */
public class GsonDemo {
    public static void main(String[] args) {
        User user = new User();
        user.setUsername("javaboy");
        user.setBirthday(new Date());
        //Gson gson = new Gson();
        GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat("yyyy-MM-dd");
        Gson gson = gsonBuilder.create();
        System.out.println("gson.toJson(user) = " + gson.toJson(user));
    }
}
